/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.manager.search;

import br.com.foxline.model.Construction;
import br.com.foxline.service.ConstructionService;
import br.com.foxline.util.Msg;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author luciano
 */
@ManagedBean
@ViewScoped
public class ManagerSearchConstruction implements Serializable{
    
    @EJB
    private ConstructionService constructionService;
    private Construction construction;
    private List<Construction> constructions;
    private Construction removeConstruction;

    @PostConstruct
    public void init(){
        this.construction = new Construction();
        this.constructions = new ArrayList<Construction>();
    }
    
    public void search(){
         constructions = constructionService.findConstruction(construction);
    }
    
    public void remove(){
        removeConstruction.setActive(Boolean.FALSE);
        constructionService.update(removeConstruction);
        this.constructions.remove(removeConstruction);
        this.removeConstruction = new Construction();
        Msg.messagemInfo(Msg.SuccessFull);
    }

    public void clear(){
        this.construction = new Construction();
    }
    
    public Construction getConstruction() {
        return construction;
    }

    public void setConstruction(Construction construction) {
        this.construction = construction;
    }

    public List<Construction> getConstructions() {
        return constructions;
    }

    public void setConstructions(List<Construction> constructions) {
        this.constructions = constructions;
    }

    public Construction getRemoveConstruction() {
        return removeConstruction;
    }

    public void setRemoveConstruction(Construction removeConstruction) {
        this.removeConstruction = removeConstruction;
    }
    
    
    
}
